#!/usr/bin/env python
import commands
import sys
from string import strip

_cli_pre = 'ssh weixin@%s -C "%s"'

"""
#ag host
10.6.97.44 ag1
10.6.97.45 ag2
10.6.97.48 ag3
10.6.97.52 ag5
10.6.97.53 ag6
10.6.97.54 ag7
10.6.97.55 ag8

"""

servers = [
    'ag1','ag2','ag3','ag5','ag6','ag7','ag8'
]



def execmd(cmd,host):
    status,output = commands.getstatusoutput(cmd)
    print 'host : %s' % host
    print  output
    print  '\n'





if __name__ == '__main__':
    cmd = strip(sys.argv[1])
    print 'CMD: %s' % cmd
    for host in servers:
        execmd(_cli_pre % (host,cmd),host)


